import Vue from 'vue'
import VRouter from 'vue-router'
Vue.use(VRouter);
export default new VRouter({
  mode: 'history',
  routes: [
    // 主界面
    {
      path: '/',
      component: () => import('@/pages/home/index.vue'),
      redirect: '/home/index',
      // 子路由
      children: [
        // 系统主页
        {
          path: '/home/index',
          component: () => import('@/pages/system/index.vue')
        },
        // 数据统计
        {
          path: '/home/sum',
          component: () => import('@/pages/sum/index.vue')
        },
        // 客户管理
        {
          path: '/home/customer',
          component: () => import('@/pages/customer/index.vue')
        },
        // 账户管理
        {
          path: '/home/logos',
          component: () => import('@/pages/logos/index.vue')
        },
        // 邮箱推送
        {
          path: '/home/emails',
          component: () => import('@/pages/emails/index.vue')
        },
        // 短信推送
        {
          path: '/home/message',
          component: () => import('@/pages/message/index.vue')
        },
        // IP资源池
        {
          path: '/home/ips',
          component: () => import('@/pages/ips/index.vue')
        }
      ]
    },
    // 错误页面
    {
      path: '/error',
      name: 'error',
      component: () => import('@/pages/error/index.vue')
    }
  ]
});

/**
 * 重写路由的push方法
 */
const routerPush = VRouter.prototype.push

VRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
};
